#ifndef REGISTER_DIALOG_H
#define REGISTER_DIALOG_H

#include <QDialog>
#include <QString>
#include "global.h"
#include <QMap>

#include "visiablelabel.h"
#include "rsacrypt.h"
namespace Ui {
class Register_Dialog;
}

class Register_Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Register_Dialog(QWidget *parent = nullptr);
    ~Register_Dialog();
signals:
    void switchLogin();
    void switchRegSuccess();
private:
    Ui::Register_Dialog *ui;
    RsaCrypt *rsacrypt_;
    //关联容器，存储ReqId和对应的处理函数
    QMap<ReqId,std::function<void(const QJsonObject &jsonObj)>>_handlers;

    //存储Edit输入格式报错
    QMap<TipErr, QString> _tip_errs;

    //添加/删除Tiperr
    void AddTipErr(TipErr te, QString tips);
    void DelTipErr(TipErr err);
    //初始化绑定ReqId和对应的处理函数
    void initHandlers();

    //check函数
    bool checkUserValid();
    bool checkEmailValid();
    bool checkPassValid();
    bool checkConfirmValid();
    bool checkVarifyValid();
    void showTip(QString str,bool is_ok);

private slots:
    void slot_reg_mod_finish(ReqId id, QString str, ErrorCodes er);
    void SlotGetCode();
    void SlotRegister();
    void SlotPassVisiable(Visiablelabel::LabelState state);
    void SlotConfirmVisiable(Visiablelabel::LabelState state);

};

#endif // REGISTER_DIALOG_H
